#!/usr/bin/env python
# -*- coding: utf-8 -*-

from flask import Flask, jsonify, request
import json


app = Flask(__name__)


@app.route("/predict", methods=['POST'])
def predict():
    # 获取数据
    res = json.loads(request.get_data())
    datas = res.get("data")
    # 模型预测
    pres = []
    for data in datas:
        x = int(data[0])
        y = int(data[1])
        pres.append({'HalfPlusOne': 0.5 * x + y})
    # 返回模型预测结果
    return jsonify(pres)


if __name__ == '__main__':
    app.run(debug=False, host='0.0.0.0')
